from rest_framework import serializers

from blog.models import BlogMsg, BlogType
from tags.serializer import TagsSerializer
from django.db.models.aggregates import Count


class BlogTypeSerializer(serializers.ModelSerializer):

    class Meta:
        model = BlogType
        fields = ('id', 'type_name', 'count')


class BlogMsgSerializer(serializers.ModelSerializer):

    blog_tags = TagsSerializer(many=True)
    blog_type = BlogTypeSerializer()

    class Meta:
        model = BlogMsg
        fields = '__all__'


